<?php

namespace core;

class SmartyView extends \Smarty
{
    private $var = [];

    public function __construct()
    {
        parent::__construct();
        $this->setCompileDir(RUN_PATH.'compile');
        $this->setCacheDir(RUN_PATH.'cache');
        $tpl = APP_PATH.C('MODULE_NAME').DS.C('TEMPLATE_DIR').DS.C('CONTROLLER_NAME');
        $this->setTemplateDir($tpl);
        if (C('CACHE')) {
            $this->cache_lifetime = C('CACHE_TIME');
            $this->setCaching(\Smarty::CACHING_LIFETIME_CURRENT);
        }
    }
    public function fetch($tpl = null, $cache_id = NULL, $compile_id = NULL, $parent = NULL)
    {
        if ($tpl == null)
            $tpl = C('ACTION_NAME').C('TEMPLATE_SUFFIX');
        return parent::fetch($tpl, $cache_id, $compile_id, $parent);
    }

    public function display($tpl = null, $cache_id = NULL, $compile_id = NULL, $parent = NULL)
    {
        if ($tpl == null)
            $tpl = C('ACTION_NAME').C('TEMPLATE_SUFFIX');
        parent::display($tpl, $cache_id, $compile_id, $parent);
    }
}
